﻿using System;
using System.Collections.Generic;
using System.Text;
using YouHP.Utility;
using YouHP.Model;
using YouHP.BLL;

namespace YouHP.Pages.Admin
{
    public class AddDisease : YouHP.Pages.BasePage
    {
        protected override void ShowPage()
        {
            base.ShowPage();

            if (IsPost)
            {
                DoPost();
            }
            else
            { 

            }
        }

        protected void DoPost()
        {
            string dszname = RequestTools.GetFormString("dszname");
            string dszintro = RequestTools.GetFormString("dszintro");
            string dszdesp = RequestTools.GetFormString("dszdesp");
            if (dszname == "" || dszname.Length < 2)
            {
                AddErrLine("疾病名称长度不能小于 2 ");
            }
            if (dszintro == "" || dszintro.Length < 2)
            {
                AddErrLine("疾病简介长度不能小于 2 ");
            }
            if (dszdesp == "" || dszdesp.Length < 2)
            {
                AddErrLine("疾病描述长度不能小于 2 ");
            }
            if (this.ErrorCount > 0)
            {
                //this.SetMetaRefresh(2, "AddDisease.aspx");
                this.SetShowBackLink(true);
                return;
            }
 
            DiseaseInfo info = new DiseaseInfo();
            info.Name = dszname;
            info.Intro = dszintro;
            info.Desp = dszdesp;
            info.PinYin = Chinese.GetPingYinFirstLetter(info.Name);
            info.Type = 1;
            info.UpdateTime = DateTime.Now;
            DiseaseBLL.Instance.AddDisease(info);
            this.AddMsgLine("疾病添加成功");
            this.SetUrl("ListDiseases.aspx");
            this.SetMetaRefresh(2, "ListDiseases.aspx");

        }
    }
}
